package harima.agameditor.common.ui;

import harima.agameditor.common.control.AwesomeEditorEnviroment;

import java.util.HashMap;

import javax.swing.JPanel;

public abstract class BaseEditorView<ControllerType> extends JPanel{

	protected HashMap<String, BaseEditorPanel<ControllerType>> panels = new HashMap<String, BaseEditorPanel<ControllerType>>();
	protected ControllerType controller;
	
	
	protected void registerPanel(BaseEditorPanel<ControllerType> panel)
	{
		panels.put(panel.getPanelId(), panel);
	}
	
	public BaseEditorPanel<ControllerType> getPanel(String name)
	{
		return panels.get(name);
	}

	public void setController(ControllerType obj) {
		controller = obj;
	}

	public ControllerType getController() {
		return controller;
	}

	public void addControllerToChildPanels() {
		for(BaseEditorPanel<ControllerType> panel : panels.values())
		{
			panel.setController(controller);
		}
	}
}
